﻿using BLL.Base;
using CommandService;
using Entity;

using Entity.DbEntity;
using Entity.SysEntity.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tools;

namespace BLL.Basis
{
  public  class DeptBLL
    {
        
        LoginInfo userLogin;
        Commands cmd;
        ReturnResult rsl;
        public DeptBLL()
        {
            //当前登录人信息
            userLogin = new LoginInfo();
            //数据交互
            cmd = new Commands();
            rsl = new ReturnResult();
        }
        /// <summary>
        /// 获取部门列表
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public ReturnResult DeptInfoList(string pageIndex, string pageSize, ref string pageCount, string conditon)
        {
            rsl = new ReturnResult();
            try
            {
                //var user = userLogin.UserInfo();
                //string conditions = "";
     
                //if (user.isAdmin.Equals(1))
                //{
                //    conditions = "status=1  and accCode='" + LoginUser.getAccCode() + "' and depCode  like '%" + deptCode + "%' and depName like '%" + deptName + "%'";
                //}
                //else
                //{
                //    conditions = "status=1  and createUser='" + user.userCode + "' and depCode like '%" + deptCode + "%' and depName like '%" + deptName + "%'";
                //}
                //DeptList = cmd.PageList<funDeptInfo>("fun_DeptInfo", pageIndex, pageSize, conditions, "id", ref pageCount);
            
                //Msg.data = DeptList;
                //Msg.result = true;
            }
            catch (Exception ex)
            {
               
            }
            return rsl;
        }
      /// <summary>
      /// 部门信息
      /// </summary>
      /// <returns></returns>
        public ReturnResult GetDeptInfo()
        {
            rsl = new ReturnResult();
            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("select * from sys_DepartMent_Info where ");
                sb.Append("status='Y' and baseCode='"+ userLogin.UserInfo().baseCode +"'");
                rsl.Data = cmd.TableToDictionary(cmd.GetDataTable(sb.ToString()));
                rsl.Result = true;
            }
            catch (Exception ex)
            {
                rsl.Message = ex.Message;
            }
            return rsl;
        }
    }
}
